class ParentDict {
    dict = new Map();
    constructor(data: any) {
        const process = (children: any, key: any) => {
            for (const child of children) {
                this.dict.set(child.id, key);
                if (Array.isArray(child.children)) {
                    process(child.children, child);
                }
            }
        };
        process(data, null);
    }
    getPid(cid: string| number) {
        return this.dict.get(cid);
    }
    areObjectsEqual(arr: any, prop: any,value: boolean) {
        // 检查数组中的所有对象是否都有该属性
        if (!arr.every((obj: any) => obj.hasOwnProperty(prop))) {
          return false;
        }
        // 比较第一个对象的该属性与其他对象
        const firstValue = arr[0][prop];
        return arr.every((obj: any) => obj[prop] === value);
    }
}

export {
    ParentDict
}